/* 侯捷 c++第一课 */
#include <iostream>
using namespace std;

class Fraction {
public:
    explicit Fraction(int num, int den = 1)
        : m_numerator(num), m_denominator(den) {
            cout << m_numerator << "/" << m_denominator << endl;
        }
    operator double() const {
        return (double)m_numerator / m_denominator;
    }
    Fraction operator+ (const Fraction& other) {
        return Fraction(m_numerator * other.m_denominator + m_denominator * other.m_numerator, 
                        m_denominator * other.m_denominator);
    }
private:
    int m_numerator;
    int m_denominator;
};

int main(int argc, char **argv)
{
    cout << "======= start =========" << endl;

    Fraction f(3, 5);
    double d = double(f) + 4;
    cout << "main:" << d << endl;

    Fraction f_sum = f + Fraction(4);
    double sum = f_sum;
    cout << "main:" << sum << endl;

    cout << "======== end ==========" << endl;
    return 0;
}
